Skip to content

test(cache): fix Windows flake in the torn-file concurrency test - #3921

Merged
trungutt merged 1 commit into
docker:mainfrom
trungutt:fix-windows-cache-test-flake
Aug 6, 2026
Merged

test(cache): fix Windows flake in the torn-file concurrency test#3921
trungutt merged 1 commit into
docker:mainfrom
trungutt:fix-windows-cache-test-flake

Conversation

@trungutt

@trungutt trungutt commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

What this PR does

Fixes a Windows-only CI flake in TestFileCache_concurrentStoreNeverYieldsTornFile (seen e.g. in this run):

open C:\...\cache.json: The process cannot access the file because it is being used by another process.

The test races a reader loop (os.ReadFile) against Store's temp-file+rename publishes to prove readers never observe a torn write. On POSIX that's a clean race: rename is atomic and the destination stays openable. On Windows, MoveFileEx(MOVEFILE_REPLACE_EXISTING) can make the destination transiently unopenable, so the reader occasionally gets ERROR_SHARING_VIOLATION — a timing artifact of the writer itself, not a torn write.

The reader loop already tolerated os.ErrNotExist (file not published yet); it now also tolerates the Windows sharing violation, via a build-tagged test helper following the existing isLockUnavailable pattern (pkg/tools/builtin/plan/lock_windows.go). The test's actual assertion — successfully read bytes always parse as valid JSON — is unchanged.

@trungutt
trungutt requested a review from a team as a code owner August 6, 2026 08:14

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

@trungutt
trungutt merged commit bd6f07e into docker:main Aug 6, 2026
11 of 12 checks passed
@aheritier aheritier added area/core Core agent runtime, session management kind/test Test-only changes labels Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Core agent runtime, session management kind/test Test-only changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants